﻿namespace BM.Tools.WebControls.MForm.Example.Core
{
    using System;
    using System.Xml;

    using Toolbox;

    public partial class InputOutput : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var toolbox = Root1.NotifyToolbox();
            toolbox.ValidationButton.Click += FillXmlTextBox;
            toolbox.NoValidationButton.Click += FillXmlTextBox;            
        }

        protected void XmlTextButtonClick(object sender, EventArgs e)
        {
            var doc = new XmlDocument();
            doc.LoadXml(XmlTextBox.Text);
            Root1.DataSource = doc;
            Root1.DataBind();
        }

        protected void FillXmlTextBox(object sender, EventArgs e)
        {
            XmlTextBox.Text = MFormToolbox.GetBuilder(Root1.OutputXml).ToString();
        }
    }
}
